package com.itheima.dubbo.samples.provider;

import com.alibaba.dubbo.rpc.RpcContext;
import com.itheima.dubbo.samples.api.EchoService;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class EchoServiceImpl implements EchoService {

    @Override
    public String echo(String message) {

        String now = new SimpleDateFormat("HH:mm:ss").format(new Date());
        System.out.println("[" + now + "] Hello " + message +", request from consumer: "
                + RpcContext.getContext().getRemoteAddress());
        return message;
    }
}
